<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('房产资产列表')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-west">
    <div class="box box-main">
        <div class="box-header">
            <div class="box-title">
                <i class="fa fa-sitemap"></i> 组织机构
            </div>
            <div class="box-tools pull-right">
                <a type="button" class="btn btn-box-tool" href="javascript:void(0)" onclick="dept()" title="管理部门"><i class="fa fa-edit"></i></a>
                <button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
                <button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新部门"><i class="fa fa-refresh"></i></button>
            </div>
        </div>
        <div class="ui-layout-content">
            <div id="tree" class="ztree"></div>
        </div>
    </div>
</div>
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <form id="formId">
                        <input type="hidden" id="deptId" value="205" name="deptId">
                        <div class="select-list">
                            <ul>
                                <li>
                                    <label>资产编号：</label>
                                    <input type="text" name="code"/>
                                </li>
                                <li>
                                    <label>资产名称：</label>
                                    <input type="text" id="name" name="name"/>
                                </li>
                                <li>
                                    <label>资产状态</label>
                                    <select name="state" id="state" th:with="type=${@dict.getType('house_state')}">
                                        <option value="">所有</option>
                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                    </select>
                                </li>
                                <li>
                                    <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                    <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                                </li>
                            </ul>
                        </div>
                    </form>
                </div>
                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="add()" shiro:hasPermission="house:house:add">
                        <i class="fa fa-plus"></i> 添加
                    </a>
                    <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="house:house:edit">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="house:house:remove">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="house:house:export">
                        <i class="fa fa-download"></i> 导出
                    </a>
                </div>
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: layout-latest-js" />
    <th:block th:include="include :: ztree-js" />
    <th:block th:include="include :: bootstrap-table-resizable-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('house:house:edit')}]];
        var removeFlag = [[${@permission.hasPermi('house:house:remove')}]];
        var houseDatas = [[${@dict.getType('house_state')}]];
        var houseTypes = [[${@dict.getType('house_type')}]];
        var housepurposeDatas = [[${@dict.getType('house_purpose')}]];
        var houseCommercialPurpose = [[${@dict.getType('commercial_purpose')}]];
        var key = [[${key}]];
        var prefix = ctx + "house/house";

        $(function() {
            var panehHidden = false;
            if ($(this).width() < 769) {
                panehHidden = true;
            }
            $('body').layout({ initClosed: panehHidden, west__size: 185, resizeWithWindow: false });
            // 回到顶部绑定
            if ($.fn.toTop !== undefined) {
                var opt = {
                    win:$('.ui-layout-center'),
                    doc:$('.ui-layout-center')
                };
                $('#scroll-up').toTop(opt);
            }
            queryUserList();
            queryDeptTree();
        });

        function queryUserList()  {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "房产资产",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键ID',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a type="button" class="btn btn-success btn-xs" href="javascript:void(0)" onclick="uploadSyncData(\'' + row.id + '\')"><i class="fa fa-file"></i>附件</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    },
                    width: 200
                },
                {
                    field: 'landAssetsId',
                    title: '土地资产ID',
                    visible: false
                },
                {
                    field: 'type',
                    title: '房产类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(houseTypes, value);
                    },
                    width: 75
                },
                {
                    field: 'purpose',
                    title: '资产用途',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(housepurposeDatas, value);
                    }
                },
                {
                    field: 'projectNo',
                    title: '项目编号'
                },
                {
                    field: 'commercialPurpose',
                    title: '商业用途',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(houseCommercialPurpose, value);
                    },
                    visible: false
                },
                {
                    field: 'code',
                    title: '资产编号'
                },
                {
                    field: 'name',
                    title: '资产名称',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,5);
                    },
                    width: 100
                },
                {
                    field: 'address',
                    title: '资产地址',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,5);
                    },
                    width: 100
                },
                {
                    field: 'position',
                    title: '区域位置'
                },
                {
                    field: 'state',
                    title: '使用状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(houseDatas, value);
                    }
                },
                {
                    field: 'distribute',
                    title: '楼层分布',
                    visible: false
                },
                {
                    field: 'acreage',
                    title: '建筑面积'
                },
                {
                    field: 'structure',
                    title: '房屋结构',
                    visible: false
                },
                {
                    field: 'buildingTime',
                    title: '修建年代',
                    visible: false
                },
                {
                    field: 'completedTime',
                    title: '竣工时间',
                    visible: false
                },
                {
                    field: 'buildingCompany',
                    title: '建设单位',
                    visible: false
                },
                {
                    field: 'adminCompany',
                    title: '管理单位',
                    visible: false
                },
                {
                    field: 'level',
                    title: '完好等级',
                    visible: false
                },
                {
                    field: 'overallDelivery',
                    title: '是否整体交付',
                    visible: false
                },
                {
                    field: 'noDeliveryCause',
                    title: '未交付原因',
                    visible: false
                },
                {
                    field: 'plotRatio',
                    title: '容积率'
                },
                {
                    field: 'propertyRightCard',
                    title: '产权证号'
                },
                {
                    field: 'deadline',
                    title: '使用期限'
                },
                {
                    field: 'cardRecordDate',
                    title: '证书登记日期',
                    visible: false
                },
                {
                    field: 'cardPlace',
                    title: '证件位置',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value,8);
                    }
                },
                {
                    field: 'longitude',
                    title: '经度',
                    visible: false
                },
                {
                    field: 'latitude',
                    title: '纬度',
                    visible: false
                },
                {
                    field: 'surveyCompany',
                    title: '测绘机构',
                    visible: false
                },
                {
                    field: 'surveyReport',
                    title: '测绘报告',
                    visible: false
                },
                {
                    field: 'remark',
                    title: '备注',
                    visible: false
                },
                {
                    field: 'createUserId',
                    title: '创建者ID',
                    visible: false
                },
                {
                    field: 'updateUserId',
                    title: '最后更新者ID',
                    visible: false
                },
                {
                    field: 'parkingLotAmount',
                    title: '车位数量',
                    visible: false
                },
                {
                    field: 'parkingLotUsed',
                    title: '已出租车位数量',
                    visible: false
                },
                {
                    field: 'parkingLotRemanent',
                    title: '闲置车位数量',
                    visible: false
                },
                {
                    field: 'usedAcreage',
                    title: '已使用面积',
                    visible: false
                },
                {
                    field: 'floorHeight',
                    title: '层高',
                    visible: false
                },
                {
                    field: 'bearingCapacity',
                    title: '承重能力(kg/m^2)',
                    visible: false
                }]
            };
            $.table.init(options);
        };

        function queryDeptTree()
        {
            var url = ctx + "system/common/deptTreeData/"+key;
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                var deptId = treeNode.id
                $("#deptId").val(deptId);
                $.ajax({
                    url: ctx+"system/common/getDictData/"+deptId,
                    type: 'post',
                    cache: false,
                    processData: false,
                    contentType: false,
                    dataType: "json",
                    success: function (result) {
                        var rows = result.rows;
                        var html=""
                        html +='<option value="">所有</option>';
                        $.each(rows,function (index,item) {
                            html +='<option value="'+item.dictValue+'">'+item.dictLabel+'</option>'
                        });
                        $("#state").html(html);
                    }
                });
                $.table.search();
            }
        };

        function uploadSyncData(id){
            $.modal.open("附件上传", ctx+"system/common/houseUpload/"+id);
        };

        $('#btnExpand').click(function() {
            $._tree.expandAll(true);
            $(this).hide();
            $('#btnCollapse').show();
        });

        $('#btnCollapse').click(function() {
            $._tree.expandAll(false);
            $(this).hide();
            $('#btnExpand').show();
        });

        $('#btnRefresh').click(function() {
            queryDeptTree();
        });

        /* 自定义重置-表单重置/隐藏框/树节点选择色/搜索 */
        function resetPre() {
            resetDate();
            $("#formId")[0].reset();
            $("#deptId").val("");
            $(".curSelectedNode").removeClass("curSelectedNode");
            $.table.search();
        };

        function dept() {
            var url = ctx + "system/assets";
            $.modal.openTab("资产管理", url);
        };
        function add(){
            var deptId = $("#deptId").val();
            $.modal.open("新增资产", prefix+"/addbyId/"+deptId);
        };
    </script>
</body>
</html>